home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 2213 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.1 KB

  1. Path: erinews.ericsson.se!usenet
  2. From: ebcjeg@ebc.ericsson.se (Jan Granqvist)
  3. Newsgroups: comp.lang.c++
  4. Subject: Runtime error when stressing application
  5. Date: Tue, 16 Jan 1996 14:44:01 GMT
  6. Organization: Ericsson
  7. Message-ID: <4dgdhv$1ko@erinews.ericsson.se>
  8. NNTP-Posting-Host: ebcp5163.ebc.ericsson.se
  9. X-Newsreader: Forte Free Agent 1.0.82
  10.  
  11. Hello everybody.
  12.  
  13. I've received this strange fault which occurs when stressing this
  14. application I'm working on, which runs under windows.
  15.  
  16. To make things short.
  17. I call lstrlen ( pointer ), where pointer is composed by combining a
  18. pointer and an offset.
  19.  
  20.     dwDestAddressSize = lstrlen( (LPCSTR)(lp_ForwardingInfo + dwOffset ))
  21. + 1;
  22.  
  23. When stressing this application CodeGuard complains about an invalid
  24. string pointer.
  25. So, I changed from lstrlen to strlen, which resulted in a GPF, which
  26. in turn I could catch in the debugger.
  27.  
  28. The call stack indicated a fault in strlen. I took a look at the
  29. stack, and saw that the argument pushed on the stack was wrong, the
  30. offset to the pointer was totally wrong, the segment was however
  31. correct.
  32.  
  33. d SS:BP
  34.  
  35.     0x43A7        correct segment value
  36.     0x0B50        wrong offset value, should have been 0x0928
  37.     0x47C7        return address
  38.     0x4235        return address
  39.  
  40. So, I took a look on the variables which creates the argument to
  41. strlen, and these showed the proper values.
  42.  
  43.     lp_ForwardList    0x43A7:0x0910
  44.     dwOffset    0x18
  45.  
  46. I then created a dummy variable
  47.  
  48.     lpDummy = (LPCSTR)(lp_ForwardingInfo + dwOffset );
  49.     lpDummy = lpDummy;
  50.  
  51. to see if it always came up with this result. And, it did. But still
  52. the variables for creating the dummy variable were right. So, I
  53. thought to myself, weird shit.
  54. I was thinking about a corrupt stack, but the return address and
  55. segment values were right.
  56. I then created a dummy function with three arguments
  57.  
  58.     void myfunc ( DWORD, LPSTR, DWORD );
  59.  
  60. that only calls strlen, which I called
  61.  
  62.     myfunc ( dwResult, (LPSTR)lp_ForwardingInfo, dwOffset );
  63.  
  64. to see which values pushed on the stack were wrong.
  65. But after I did this small change, it works, I couldn't get a GPF.
  66. Now, somebody tell me, what's going on.
  67.  
  68. It was compiled using VC++ 1.51, large model, no optimization.
  69.  
  70. I'm waiting eagerly for reply.
  71.  
  72.  
  73.